package com.lxq.LeetCode.isPalindrome;

public class Solution {
    public static void main(String[] args) {
        boolean res = isPalindrome(1073773701);
        System.out.println(res);
    }

    public static boolean isPalindrome(int x) {
        if (x < 0) {
            return false;
        } else if (x < 10) {
            return true;
        } else {
            int changeNum = 0;
            int originNum = x;
            do {
                changeNum = changeNum * 10 + originNum % 10;
                originNum = originNum / 10;
            } while (originNum != 0);

            return changeNum == x;
        }
    }
//    public static boolean isPalindrome(int x) {
//        boolean res = false;
//        String originNum = String.valueOf(x);
//        String changeNum = "";
//        StringBuffer sb = new StringBuffer(originNum);
//        sb.reverse();
//        changeNum = sb.toString();
//        res = changeNum.equals(originNum);
//
//        return res;
//    }
}
